﻿using Platform.Logger;
using System.Windows;

namespace Platform.Shell
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Logs.LogError((Exception)e.ExceptionObject);
            };

            Current.DispatcherUnhandledException += (s, e) =>
            {
                Logs.LogError(e.Exception);
            };

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                Logs.LogError(e.Exception);
            };

            
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Logs.LogInfo("启动应用程序");
        }

        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            Logs.LogInfo("关闭应用程序");

        }

        public new static App Current => (App)Application.Current;

        
    }

}
